package org.jeecg.modules.demo.jxcx.controller;

import com.alibaba.fastjson.JSONObject;
import org.jeecg.modules.demo.jxcx.Utils.R;
import org.jeecg.modules.demo.jxcx.po.JxcInventory;
import org.jeecg.modules.demo.jxcx.service.JxcInventoryService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping({"jxcInventory"})
public class JxcInventoryController {

    private static Logger logger = LoggerFactory.getLogger(JxcInventoryController.class);
    @Autowired
    private JxcInventoryService jxcInventoryService;

    @PostMapping({"/queryall"})
    @ResponseBody
    public R queryall(@RequestBody JSONObject params) {
        String companyId = params.getString("companyId");
        return new R().ok(jxcInventoryService.getByCompanyId(companyId));
    }

    @PostMapping({"add"})
    public R insert(@RequestBody JxcInventory jxcInventory) {
        return jxcInventoryService.add(jxcInventory);
    }

    @DeleteMapping
    public R delete(@RequestBody JSONObject params) {
    	String id = params.getString("id");
    	return new R().ok(jxcInventoryService.removeById(id));
    }
}
